package com.yzt.sys.service.impl;

import com.yzt.sys.entity.RolePermission;
import com.yzt.sys.mapper.RolePermissionMapper;
import com.yzt.sys.service.IRolePermissionService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yzt.base.service.impl.BaseServiceImpl;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

/**
 * <p>
 * 角色_权限关联表 服务实现类
 * </p>
 *
 * @author Y
 * @since 2020-12-21
 */
@Service
public class RolePermissionServiceImpl extends BaseServiceImpl<RolePermissionMapper, RolePermission>
		implements IRolePermissionService {

	@Override
	public List<Long> getPermissionIds(List<Long> roleIds) {
		List<Long> permissionIds = this.listObjs(Wrappers.<RolePermission>lambdaQuery()
				.select(RolePermission::getPermissionId).in(RolePermission::getRoleId, roleIds), a -> {
					return Long.valueOf(a.toString());
				}).stream().distinct().collect(Collectors.toList());
		return permissionIds;
	}

}
